#import <stdio.h>
#import <stdbool.h>
#import "Deamon.h"
#import "Weapon.h"

int main()
{
	srandom(time(0));
	Deamon* deamon1 = [Deamon new];
	Deamon* deamon2 = [Deamon new];

	Weapon* swordForDeamon1 =[Weapon new];
	Weapon* swordForDeamon2 =[Weapon new];
	
	[swordForDeamon1 name: "Sword from lighting"];
	[swordForDeamon1 minAttackPower: 0];
	[swordForDeamon1 maxAttackPower: 5];
	
	[swordForDeamon2 name: "Sword from snowman of sorrows"];
	[swordForDeamon2 minAttackPower: 3];
	[swordForDeamon2 maxAttackPower: 4];

	[deamon1 lvl:1];
	[deamon1 hitpoints:25];
	[deamon1 name: "Thunder Caller"];
	[deamon1 useWeapon: swordForDeamon1];
	
	[deamon2 lvl:1];
	[deamon2 hitpoints:25]; 
	[deamon2 name: "Frostbeast"];
	[deamon2 useWeapon: swordForDeamon2];

	int turn = -1, attackHp=0;
	printf("\n\n%s vs %s\n\n", [deamon1 toString], [deamon2 toString]);
	while([deamon1 isDead] == false && [deamon2 isDead] == false) { // both deamons are alive
		attackHp = [(turn == -1 ? deamon1 : deamon2) hit];
		printf("\n%s hits %s with %d",[(turn == -1 ? deamon1 : deamon2) name], [(turn == -1 ? deamon2 : deamon1) name], attackHp);
		[(turn == -1 ? deamon2 : deamon1) receiveHit: attackHp];
		turn *= -1;
	}
	printf("\n\nThe winner of epic battle is %s\n", [deamon1 isDead] ? [deamon2 name] : [deamon1 name]);
	return 0;
}
